/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.ShareInfo.Discover;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.mailbox.OperationContext;
/*    */ import com.zimbra.cs.service.account.GetShareInfo.ResultFilter;
/*    */ import com.zimbra.cs.service.account.GetShareInfo.ResultFilterByTarget;
/*    */ import com.zimbra.cs.service.account.GetShareInfo.ShareInfoVisitor;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.GetShareInfoRequest;
/*    */ import com.zimbra.soap.admin.message.GetShareInfoResponse;
/*    */ import com.zimbra.soap.type.AccountBy;
/*    */ import com.zimbra.soap.type.AccountSelector;
/*    */ import com.zimbra.soap.type.GranteeChooser;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetShareInfo
/*    */   extends ShareInfoHandler
/*    */ {
/* 43 */   private static final String[] TARGET_ACCOUNT_PATH = { "owner" };
/*    */   
/* 45 */   protected String[] getProxiedAccountElementPath() { return TARGET_ACCOUNT_PATH; }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean defendsAgainstDelegateAdminAccountHarvesting()
/*    */   {
/* 52 */     return true;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 58 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 59 */     OperationContext octxt = getOperationContext(zsc, context);
/* 60 */     Provisioning prov = Provisioning.getInstance();
/* 61 */     GetShareInfoRequest req = (GetShareInfoRequest)JaxbUtil.elementToJaxb(request);
/* 62 */     GranteeChooser granteeChooser = req.getGrantee();
/*    */     
/* 64 */     byte granteeType = com.zimbra.cs.service.account.GetShareInfo.getGranteeType(granteeChooser == null ? null : granteeChooser.getType());
/*    */     
/* 66 */     String granteeId = null;
/* 67 */     String granteeName = null;
/* 68 */     if (granteeChooser != null) {
/* 69 */       granteeId = granteeChooser.getId();
/* 70 */       granteeName = granteeChooser.getName();
/*    */     }
/*    */     
/* 73 */     Account ownerAcct = null;
/* 74 */     Key.AccountBy acctBy = req.getOwner().getBy().toKeyAccountBy();
/* 75 */     String accountSelectorKey = req.getOwner().getKey();
/* 76 */     ownerAcct = prov.get(acctBy, accountSelectorKey);
/*    */     
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/* 82 */     defendAgainstAccountOrCalendarResourceHarvesting(ownerAcct, acctBy, accountSelectorKey, zsc, Rights.Admin.R_adminLoginAs, Rights.Admin.R_adminLoginCalendarResourceAs);
/*    */     
/* 84 */     GetShareInfoResponse response = new GetShareInfoResponse();
/*    */     
/* 86 */     GetShareInfo.ResultFilter resultFilter = new GetShareInfo.ResultFilterByTarget(granteeId, granteeName);
/* 87 */     GetShareInfo.ShareInfoVisitor visitor = new GetShareInfo.ShareInfoVisitor(prov, response, null, resultFilter);
/* 88 */     ShareInfo.Discover.discover(octxt, prov, null, granteeType, ownerAcct, visitor);
/* 89 */     visitor.finish();
/*    */     
/* 91 */     return zsc.jaxbToElement(response);
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 96 */     relatedRights.add(Rights.Admin.R_adminLoginAs);
/* 97 */     relatedRights.add(Rights.Admin.R_adminLoginCalendarResourceAs);
/* 98 */     notes.add("If the target is an account, need the adminLoginAs right; If the target is a calendar resource, need the R_adminLoginCalendarResourceAs right.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/GetShareInfo.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */